package com.hfh.reflect;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author hfh
 * @Date 2022 09 14 17 12
 **/
public class Test {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
        List<String> list = new ArrayList<>();
        Field field = ArrayList.class.getDeclaredField("size");
        field.setAccessible(true);
        field.set(list,10);

        list.add("测试");
        System.out.println(list.size());
        System.out.println(list.get(10));
    }
}
